package cn.lingyangwl.agile.food.model.entity;

import cn.lingyangwl.agile.model.BasePO;
import cn.lingyangwl.agile.food.model.constants.StockInOutStatus;
import cn.lingyangwl.agile.food.model.constants.StockInOutType;
import cn.lingyangwl.agile.tenant.core.DataIsolation;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 库存单据记录
 *
 * @author shenguangyang
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("food_stock_document")
@DataIsolation(filterMainTenant = true, filterTenant = true, tableName = "food_stock_document")
public class StockDocument extends BasePO {
    @TableId
	private Long id;
	
	/**
	 * 库存单号
	 */
	private String stockNo;
	
	/**
	 * 操作人id
	 */
	private Long operaterId;
	
	/**
	 * 操作人用户名
	 */
	private String operaterName;
	
	/**
	 * 操作时间
	 */
	private Date operateTime;
	
	/**
	 * 库存单据类型, 正数表示入库, 负数表示出库
	 * @see StockInOutType
	 */
	private Integer type;
	
	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date createdAt;
	
	/**
	 * 备注
	 */
	private String remark;
	
	/**
	 * 总金额
	 */
	private BigDecimal totalPrice;
	
	/**
	 * 租户id(门店)
	 */
	private Long tenantId;
	
	/**
	 * 主租户id(总店)
	 */
	private Long mainTenantId;
	
	/**
	 * 状态, 1: 待审核, 2: 已审核 3. 拒绝
	 * @see StockInOutStatus
	 */
	private String status;
	
	/**
	 * 拒绝理由
	 */
	private String refuseReason;
	
	/**
	 * 审核时间
	 */
	private Date auditTime;

    public static LambdaQueryWrapper<StockDocument> lqw() {
		return Wrappers.lambdaQuery();
	}
}
